define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	
	require("cordova!com.justep.cordova.plugin.qq");
	require("cordova!com.justep.cordova.plugin.weixin.v3");

	var Model = function(){
	    this.thumb = "http://www.xjzlhy.com:81";
	    this.decription = '';
	    this.title = '';
		this.callParent();
		
	};



	

	Model.prototype.modelParamsReceive = function(event){
	    var me = this;
	    var id = this.getContext().getRequestParameter("id");
	    var url = "http://www.xjzlhy.com:81/ex_community/a/api/community/getClassInfuById?callback=?";
	    $.getJSON(url,{id:id},function(data){
	    	if(data && data.data){
	    		me.comp("title").set({value:data.data.title});
	    		me.comp("description").set({value:data.data.description});
	    		var contentId = me.getIDByXID("content");
				$("#"+contentId).html(data.data.content);
				$("#"+contentId +" p").css("text-indent","0px");
				
				me.thumb += data.data.image;
				me.decription = data.data.description;
				me.title = data.data.title;	
				me.id = id;	    
	    	}
	   
	   
	    });
	    
	    
//		this.comp("title").set({value:event.params.title});
//		this.comp("description").set({value:event.params.description});
//		
//		var contentId = this.getIDByXID("content");
//		$("#"+contentId).html(event.params.content);
//		$("#"+contentId +" p").css("text-indent","0px");
//		this.thumb += event.params.image;
//		this.decription = event.params.description;
//		this.title = event.params.title;
	};

	Model.prototype.sharePopupBtnClick = function(event){
		this.comp("shareMenu").show();
//		var url = window.location.href;
//		plugins.socialsharing.share("起步科技", null, null, url);

	};

	Model.prototype.friendCircleClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		function error(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		navigator.weixin.share({
			message : {
				title : me.title,
				description : "分享到朋友圈",
				//mediaTagName : "Media Tag Name(optional)",
				thumb : me.thumb,
				media : {
					//type: navigator.weixin.Type.WEBPAGE, // webpage
					webpageUrl : window.location.href
				// webpage
				}
			},
			scene : navigator.weixin.Scene.TIMELINE
		}, success, error);

	};

	Model.prototype.qqZoneClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
	    }
	    function error(result) {
	        justep.Util.hint("分享失败", {type:'danger'});
	    }
	    var args = {};
	  //  args.url = location.href.split('#')[0];
        args.url = location.href;
//	    alert(args.url);
        //args.url = "http://10.1.62.97:8080"+require.toUrl("$UI/communityOto/category/categoryInfo.w.html?id="+this.id);
        
	    args.title = me.title;
	    args.description = me.decription;
	   // var shareImg = require.toUrl('$UI/communityOto/img/share_icon.png');
	    args.imageUrl = [me.thumb];
	    
	    args.appName = "社区便民服务平台";
	 
	    navigator.QQ.shareToQzone(success, error, args);

	};

	Model.prototype.weixinClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		function error(result) {
			alert(JSON.stringify(result));
		}
		navigator.weixin.share({
			message : {
				title : me.title,
				description : "分享到微信",
				//mediaTagName : "Media Tag Name(optional)",
				thumb : me.thumb,
				media : {
					// type: weixin.Type.WEBPAGE, // webpage
					webpageUrl : window.location.href
				// webpage
				}
			},
			scene : navigator.weixin.Scene.SESSION
		}, success, error);
	};

	Model.prototype.qqClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		function error(result) {
			justep.Util.hint("分享失败", {type:'danger'});
		}
		var args = {};
		
		//args.url = location.href.split('#')[0];
		args.url = location.href;
		//alert(location.href.split(':')[0]);
		//args.url = "http://10.1.62.97:8080"+require.toUrl("$UI/communityOto/category/categoryInfo.w.html?id="+this.id);
		//alert(args.url);
	    args.title = me.title;
	    args.description = me.decription;
	    //var shareImg = require.toUrl('$UI/communityOto/img/share_icon.png');
	    args.imageUrl = [me.thumb];
	    
	    args.appName = "社区便民服务平台";
		navigator.QQ.shareToQQ(success, error, args);

	};

	return Model;
});